-- act命令延申处理

local mis_uu = require('modules.commhm.utils')
local mis_bit = require('bit')
local mis_config = require('mis_config');
local log       = require("modules.commhm.log");
local uu = mis_uu
local ngx = ngx
local pairs = pairs
local next = next
local math_floor = math.floor
local math_ceil = math.ceil
local math_max = math.max
local math_min = math.min
local math_random = math.random
local math_randomseed = math.randomseed
local math_huge = math.huge
local string_match = string.match
local string_format = string.format
local os_date = os.date
local bor = mis_bit.bor
local band = mis_bit.band
local bnot = mis_bit.bnot
local lshift = mis_bit.lshift
local tonumber = tonumber
local tostring = tostring

local table_insert = table.insert

local mis_data = nil
local mis_log = nil
local mis_bridge = nil
local mis_common = nil
local mis_condition = nil
local mis_calcu = nil
local mis_qps = nil
local mis_awakening = nil
local mis_boat_festival = nil
local t_retCode = nil
local t_retCodeMsg = nil
local mis_viptheme = nil
local s_CONTEST_MAP = mis_config.t_workType.s_CONTEST_MAP
local s_CONTEST_VIDEO = mis_config.t_workType.s_CONTEST_VIDEO
local s_CONTEST_SOCIAL = mis_config.t_workType.s_CONTEST_SOCIAL
local s_TANG_YEAR = mis_config.t_workType.s_TANG_YEAR
local s_YEAR_BEAST = mis_config.t_workType.s_YEAR_BEAST
local s_WEALTH_GOD = mis_config.t_workType.s_WEALTH_GOD
local s_LANTERN_FESTIVAL = mis_config.t_workType.s_LANTERN_FESTIVAL
local s_YEAR_ROLL = mis_config.t_workType.s_YEAR_ROLL
local s_TANG_PEOPLE = mis_config.t_workType.s_TANG_PEOPLE
local s_SHARE_ACTIVITY = mis_config.t_workType.s_SHARE_ACTIVITY
local s_FLOWER_XIAOLOU = mis_config.t_workType.s_FLOWER_XIAOLOU
local s_MINI_PARTY = mis_config.t_workType.s_MINI_PARTY
local s_VOID_INVADE = mis_config.t_workType.s_VOID_INVADE
local s_CREATE_CONVOY = mis_config.t_workType.s_CREATE_CONVOY
local s_BUILD_GREATWALL = mis_config.t_workType.s_BUILD_GREATWALL
local s_ANNIVERSARY_ROLL = mis_config.t_workType.s_ANNIVERSARY_ROLL
local s_MINI_WORKER_MISSION = mis_config.t_workType.s_MINI_WORKER_MISSION
local s_AWAKENING_HOMEPAGE = mis_config.t_workType.s_AWAKENING_HOMEPAGE
local s_AWAKENING_BOOKS = mis_config.t_workType.s_AWAKENING_BOOKS
local s_AWAKENING_MOVIE = mis_config.t_workType.s_AWAKENING_MOVIE
local s_BOAT_FESTIVAL_ACTIVITY = mis_config.t_workType.s_BOAT_FESTIVAL_ACTIVITY
local S_ALL_CREATE = mis_config.t_workType.S_ALL_CREATE
local s_DOULUODALU = mis_config.t_workType.s_DOULUODALU
local s_VIP_THEME  = mis_config.t_workType.s_VIP_THEME

--------------------------------------------------------------
local mis_extend = {
	s_name = string.match(debug.getinfo(1).short_src, '.*/(.*).lua');	-- 模块名称
}
local this = mis_extend

--------------------------------------------------------------
-- 说明：模块包含
-- 参数：模块表
this.modules_include = function(t_moddules)
	mis_data = t_moddules.mis_data
	mis_log = t_moddules.mis_log
	mis_bridge = t_moddules.mis_bridge
	mis_common = t_moddules.mis_common
	mis_condition = t_moddules.mis_condition
	mis_calcu = t_moddules.mis_calcu
	mis_qps = t_moddules.mis_qps
	mis_awakening = t_moddules.mis_awakening
	t_retCode = mis_config.t_retCode
	t_retCodeMsg = mis_config.t_retCode_Msg
	mis_boat_festival = t_moddules.mis_boat_festival
	mis_viptheme = t_moddules.mis_viptheme

	-- 觉醒活动首页
	this.missionStatus[s_AWAKENING_HOMEPAGE] = mis_awakening.share_mission_status		-- 任务状态获取额外处理
	this.missionAward[s_AWAKENING_HOMEPAGE]  = mis_awakening.share_mission_status		-- 任务奖励领取额外处理

	-- 觉醒秘籍
	this.missionStatus[s_AWAKENING_BOOKS] = mis_awakening.share_mission_status			-- 任务状态获取额外处理
	this.missionEvent[s_AWAKENING_BOOKS]  = mis_awakening.share_mission_event_check		-- 任务事件触发额外处理
	this.missionAward[s_AWAKENING_BOOKS]  = mis_awakening.share_mission_status			-- 任务奖励领取额外处理
	this.missiopCode[s_AWAKENING_BOOKS]   = mis_awakening.share_mission_code_exchagne	-- 密码兑换额外处理

	-- 觉醒发布会
	this.missionStatus[s_AWAKENING_MOVIE] = mis_awakening.share_mission_status			-- 任务状态获取额外处理
	this.missionEvent[s_AWAKENING_MOVIE]  = mis_awakening.share_mission_event_check		-- 任务事件触发额外处理
	this.missionAward[s_AWAKENING_MOVIE]  = mis_awakening.share_mission_status			-- 任务奖励领取额外处理

	-- 端午节活动 --密集处理
	this.missiopCode[s_BOAT_FESTIVAL_ACTIVITY]   = mis_boat_festival.share_mission_code_exchagne	-- 密码兑换额外处理

	-- 会员主题
	this.missionEventCore[s_VIP_THEME]   = mis_viptheme.share_missionEventCore   -- 事件触发核心逻辑
end

-- 任务逻辑处理
this.missionPre = {}
this.missionStatus = {}
this.missionEventCore = {}
this.missionEvent = {}
this.missionAward = {}
this.missionAwardCore = {}
this.missionExchange = {}
this.missionExchangeStatus = {}
this.missionAddCurrency = {}
this.missiopCode = {}
this.bind_phone_deal = {}

-- 抽奖逻辑处理
this.shareRollStatus = {}
this.shareRoll = {}


--通用熔断
local function check_is_block(s_type)

	local flag = mis_data.t_share_mission[s_type].t_conf.block_max or 1000
	local n_qps = mis_qps.mark(s_type)
	if n_qps > flag then
		mis_log.print("fuckmiserror","check_is_block-",ngx.worker.id(),n_qps,ngx.ctx.t_params.uin,s_type,flag)
		return t_retCode.n_HOT_ACTIVITY_AHEAD, t_retCodeMsg[t_retCode.n_HOT_ACTIVITY_AHEAD]
	end

	return t_retCode.n_OK, 'success'
end

-- 任务事件公共处理逻辑
this.share_mission_event_core = function(t_userData, s_type, n_event, n_value)
	local t_params 			= ngx.ctx.t_params
	local n_nowTime 		= mis_data.get_server_time()
	local t_taskConf 		= uu.table_value_copy(mis_data.t_share_mission[s_type])
	local t_mission,t_temp	= {}
	local t_update			= {}
	local s_logType			= s_type .. '_record'

	if not(t_userData and mis_uu.tableNotEmpty(t_userData) and t_userData.tasks and t_userData.tasks[s_type]) then
		return t_retCode.n_PARAM_ERR, "param error"
	end
	if not(s_type and n_value) then
		return t_retCode.n_PARAM_ERR, "param error 2"
	end
	if not(t_taskConf and t_taskConf.t_conf and t_taskConf.t_conf.t_mission) then
		return t_retCode.n_WORK_ERR, 'The mission is not exist!'
	end

	-- 获取子任务配置
	t_temp = t_taskConf.t_conf
	for k, v in pairs(t_temp.t_mission) do
		if k == n_event then
			t_mission = v
			break
		end
	end

	if not (t_mission and mis_uu.tableNotEmpty(t_mission)) then
		return t_retCode.n_NO_EVENT_TYPE, "mission not exist"
	end

	-- 更新任务进度、状态
	t_userData.tasks[s_type] = t_userData.tasks[s_type] or {}

	for k, v in pairs(t_mission) do
		local t_task = t_userData.tasks[s_type][v.n_subTaskId]
		if not t_task then
			t_task = {status = 0, progress = 0, refreshTime = 0, event = n_event  }
		end

		-- 更新进度
		if t_task.status == 0 then
			-- 获得指定道具类型的任务
			if n_event == 30 then
				if v.n_gainItem == n_value then
					t_task.progress	= t_task.progress + 1
					t_task.refreshTime 	= n_nowTime
					t_update[v.n_subTaskId] = 1
				end
			elseif n_event == 33 or n_event == 34 or n_event == 38 then
				t_task.progress		= math_min(v.n_target, n_value)
				t_task.refreshTime 	= n_nowTime
				t_update[v.n_subTaskId] = t_task.progress
			else
				if t_task.progress + n_value > v.n_target then
					t_update[v.n_subTaskId] = v.n_target - t_task.progress
				else
					t_update[v.n_subTaskId] = n_value
				end
				t_task.progress = t_task.progress + n_value
				t_task.refreshTime 	= n_nowTime
			end
		end
		-- 任务完成
		if t_task.status == 0 and v.n_target and t_task.progress >= v.n_target then
			t_task.status 		= 1
			t_task.progress		= v.n_target
			t_task.refreshTime 	= n_nowTime
			
			--埋点数据
			mis_log.remote_pure_day(s_logType, mis_common.table_to_json({
				key = 'finish';
				ip = t_params.s_remoteAddr or ngx.ctx.xff or ngx.var.remote_addr or "nil";
				uin = t_params.uin;
				time = n_nowTime;
				country = t_params.country or 'nil';
				apiid = t_params.apiid or 'nil';
				ver = t_params.ver or 'nil';
				lang = t_params.lang or 'nil';
				type = s_type;
				event = n_event;
				taskid = v.n_subTaskId;
				value = n_value;
			}))
		end
		t_userData.tasks[s_type][v.n_subTaskId] = t_task
	end

	return t_retCode.n_OK, t_userData, t_update
end

-- 任务领奖公共处理逻辑
this.share_mission_getaward_core = function(t_userData, s_type, n_subTaskId, n_mode, t_mission, t_award)
	local t_params 			= ngx.ctx.t_params
	local n_nowTime 		= mis_data.get_server_time()
	local s_logType			= s_type .. '_getaward'
	local t_subTask
	if not(s_type and n_mode and t_userData and mis_uu.tableNotEmpty(t_userData) and
			t_userData.tasks and mis_uu.tableNotEmpty(t_userData.tasks) and
			t_userData.tasks[s_type] and mis_uu.tableNotEmpty(t_userData.tasks[s_type]) and
			t_mission and mis_uu.tableNotEmpty(t_mission) and
			t_mission.t_bonus and mis_uu.tableNotEmpty(t_mission.t_bonus)) then
		mis_log.day("share_mission_error", "share_mission_getaward_core param error|" .. t_params.uin .. '|' .. s_type)
		return t_retCode.n_PARAM_ERR, "Param error"
	end

	-- 更新领奖状态
	t_subTask = t_userData.tasks[s_type][n_subTaskId]
	if not t_subTask then
		mis_log.day("share_mission_error", "share_mission_getaward_core Invalid reward|" .. t_params.uin .. '|' .. s_type)
		return t_retCode.n_OPER_ERR, 'Invalid reward'
	end

	if t_subTask.status == 1 then
		t_subTask.status 		= 2
		t_subTask.mode			= n_mode				-- 0 手动领奖；1自动领奖
		t_subTask.rewardTime 	= n_nowTime

		-- 奖励
		if t_award then
			for k, v in pairs(t_mission.t_bonus) do
				if v.s_itemId == mis_config.t_specialItem.s_SHARE
				or v.s_itemId == mis_config.t_specialItem.s_SHARE02
				or v.s_itemId == mis_config.t_specialItem.s_SHARE03 then
					table_insert(t_award.share, {id = v.s_itemId, num = v.n_num})
				else
					table_insert(t_award.items, {id = v.s_itemId, num = v.n_num})
				end
			end
		end
	else
		mis_log.day("share_mission_error", "share_mission_getaward_core Invalid status|" .. t_params.uin .. '|' .. s_type .. "|" .. uu.to_str(n_subTaskId) .. "|" .. uu.to_str(n_mode) .. "|" .. uu.to_str(t_subTask.status))
		return t_retCode.n_OPER_ERR, 'Invalid status'
	end

	--埋点数据
	mis_log.remote_pure_day(s_logType, mis_common.table_to_json({
		key = 'getaward';
		ip = t_params.s_remoteAddr or ngx.ctx.xff or ngx.var.remote_addr or "nil";
		uin = t_params.uin;
		time = n_nowTime;
		country = t_params.country or 'nil';
		apiid = t_params.apiid or 'nil';
		ver = t_params.ver or 'nil';
		lang = t_params.lang or 'nil';
		type = s_type;
		task = n_subTaskId;
		mode = n_mode;
		bonus = t_award or {};
	}))

	return t_retCode.n_OK, t_userData
end

-- 通用兑换-获得兑换卷
local function exchange_award(s_type, t_user, t_userData, t_award, t_resp, n_exchangeType)
	-- 初始化
	t_userData.award_num = t_userData.award_num or {}
	t_userData.award_num[s_type] = t_userData.award_num[s_type] or 0
	t_userData.exchange_num = t_userData.exchange_num or 0

	-- 记录兑换卷
	for i = 1, #t_award.share do
		if t_award.share[i].id == mis_config.t_specialItem.s_SHARE then
			if n_exchangeType and n_exchangeType == 1 then
				t_userData.award_num[s_type] = t_userData.award_num[s_type] + t_award.share[i].num
			else
				t_userData.exchange_num = t_userData.exchange_num + t_award.share[i].num
			end
		end
	end

	-- 兑换卷放入回复数据
	t_resp.award_num = t_userData.award_num[s_type]
	t_resp.exchange_num = t_userData.exchange_num

	return t_retCode.n_OK
end

-- 通用兑换-查询兑换卷
local function exchange_query(s_type, t_user, t_userData, t_resp)
	if t_userData.award_num and t_userData.award_num[s_type] then
		t_resp.award_num = t_userData.award_num[s_type]
	else
		t_resp.award_num = 0
	end
	t_resp.exchange_num = t_userData.exchange_num or 0

	return t_retCode.n_OK
end

-- 宝箱抽奖公共处理逻辑
this.share_roll_core = function(t_user, t_userData, t_resp)
	local t_params 			= ngx.ctx.t_params
	local n_uin 			= t_params.uin
	local s_type			= t_params.mission_type
	local t_taskConf 		= mis_data.t_share_mission[s_type]
	local n_now				= mis_data.offset_now_v2(t_taskConf)
	local s_logType			= s_type .. '_shareRoll'
	local n_code, s_desc, t_rollConf
	local n_rand, n_sum, t_bonus, t_shareAward
	
	if not (t_taskConf.t_conf and t_taskConf.t_conf.t_shareRoll) then
		log.day_list("share_roll_error" ,"share_roll extend", "no roll config", s_type, n_uin, uu.to_str(t_userData))
		return t_retCode.n_WORK_ERR, 'no roll config'
	end

	t_rollConf = t_taskConf.t_conf.t_shareRoll
	if t_rollConf.n_totalWeight <= 0 then
		log.day_list("share_roll_error" ,"share_roll extend", "total weight is zero", s_type, n_uin, uu.to_str(t_userData))
		return t_retCode.n_WORK_ERR, 'roll config error'
	end

    -- 加权随机选择奖励
    n_rand = math_random(1, t_rollConf.n_totalWeight)
    n_sum = 0
    for _, v in ipairs(t_rollConf.t_awards) do
		if (n_sum + 1) <= n_rand and n_rand <= n_sum + v.n_weight then
			t_bonus = v
			break
		end
		n_sum = n_sum + v.n_weight
    end

    if t_bonus == nil then
		log.day_list("share_roll_error" ,"share_roll extend", "roll error", s_type, n_uin, n_rand, n_sum, uu.to_str(t_rollConf))
		return t_retCode.n_WORK_ERR, 'roll config error'
    end

	-- 抽中活动货币
	if t_bonus.s_itemId == mis_config.t_specialItem.s_SHARE then
		t_shareAward = {share = {{id = mis_config.t_specialItem.s_SHARE, num = t_bonus.n_num}}}
		exchange_award(s_type, t_user, t_userData, t_shareAward, t_resp, t_rollConf.n_exchange_type)
		if t_rollConf.n_specialItemId and t_rollConf.n_specialItemId ~= 0 then
			t_resp.bonus = {{id = t_rollConf.n_specialItemId, num = t_bonus.n_num}}
		else
			t_resp.bonus = {{id = t_bonus.s_itemId, num = t_bonus.n_num}}
		end
	else
		t_resp.bonus = {{id = t_bonus.s_itemId, num = t_bonus.n_num}}
		n_code, s_desc = mis_data.add_items(t_params.uin, t_resp.bonus, s_type, 'share_roll')
		if n_code ~= t_retCode.n_OK then
			mis_log.day("share_roll_error","share_roll extend add_items error|" .. t_params.uin .. '|' .. s_type .. '|' .. uu.to_str(n_code) .. '|' .. uu.to_str(s_desc) .. '|' .. uu.to_str(t_resp.bonus))
			return n_code, s_desc
		end
	end

	--埋点数据
	mis_log.remote_pure_day(s_logType, mis_common.table_to_json({
		key = 'shareRoll';
		ip = t_params.s_remoteAddr or ngx.ctx.xff or ngx.var.remote_addr or "nil";
		uin = t_params.uin;
		time = mis_data.get_server_time();
		country = t_params.country or 'nil';
		apiid = t_params.apiid or 'nil';
		ver = t_params.ver or 'nil';
		lang = t_params.lang or 'nil';
		bonus = t_resp.bonus or {};
	}))

	return t_retCode.n_OK
end

-- 年度投票地图作者评选状态逻辑
this.missionStatus[s_CONTEST_MAP] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(s_CONTEST_MAP, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 年度投票地图作者评选事件逻辑
this.missionEvent[s_CONTEST_MAP] = function(t_user, t_userData, t_resp)
	return exchange_query(s_CONTEST_MAP, t_user, t_userData, t_resp)
end

-- 年度投票地图作者评选领奖逻辑
this.missionAward[s_CONTEST_MAP] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(s_CONTEST_MAP, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 年度投票视频作者评选状态逻辑
this.missionStatus[s_CONTEST_VIDEO] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(s_CONTEST_VIDEO, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 年度投票视频作者评选事件逻辑
this.missionEvent[s_CONTEST_VIDEO] = function(t_user, t_userData, t_resp)
	return exchange_query(s_CONTEST_VIDEO, t_user, t_userData, t_resp)
end

-- 年度投票视频作者评选领奖逻辑
this.missionAward[s_CONTEST_VIDEO] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(s_CONTEST_VIDEO, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 年度投票社区作者评选状态逻辑
this.missionStatus[s_CONTEST_SOCIAL] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(s_CONTEST_SOCIAL, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 年度投票社区作者评选事件逻辑
this.missionEvent[s_CONTEST_SOCIAL] = function(t_user, t_userData, t_resp)
	return exchange_query(s_CONTEST_SOCIAL, t_user, t_userData, t_resp)
end

-- 年度投票社区作者评选领奖逻辑
this.missionAward[s_CONTEST_SOCIAL] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(s_CONTEST_SOCIAL, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 大唐中国年-迎唐年状态逻辑
this.missionStatus[s_TANG_YEAR] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(s_TANG_YEAR, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 大唐中国年-迎唐年事件逻辑
this.missionEvent[s_TANG_YEAR] = function(t_user, t_userData, t_resp)
	return exchange_query(s_TANG_YEAR, t_user, t_userData, t_resp)
end

-- 大唐中国年-迎唐年领奖逻辑
this.missionAward[s_TANG_YEAR] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(s_TANG_YEAR, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 大唐中国年-战年兽状态逻辑
this.missionStatus[s_YEAR_BEAST] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	local s_type			= s_YEAR_BEAST
	local t_taskConf 		= mis_data.t_share_mission[s_type]

	-- 战年兽全服挑战
	if t_taskConf and t_taskConf.t_conf and t_taskConf.t_conf.t_mission and t_taskConf.t_conf.t_mission[33] then
		local t_sysUser = mis_data.get_user(1)
		local n_code, t_sysUserData = t_sysUser:get_share_mission_data(s_type, true, true)

		if n_code ~= t_retCode.n_OK then
			mis_log.day("share_mission_error","year_beast_event error")
			return n_code
		end

		t_sysUserData.n_yearBeastNum = t_sysUserData.n_yearBeastNum or 0
		this.share_mission_event_core(t_userData, s_type, 33, t_sysUserData.n_yearBeastNum)
	end
	return exchange_award(s_YEAR_BEAST, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 大唐中国年-战年兽事件逻辑
this.missionEvent[s_YEAR_BEAST] = function(t_user, t_userData, t_resp)
	return exchange_query(s_YEAR_BEAST, t_user, t_userData, t_resp)
end

-- 大唐中国年-战年兽领奖逻辑
this.missionAward[s_YEAR_BEAST] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(s_YEAR_BEAST, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 大唐中国年-迎财神前置逻辑
this.missionPre[s_WEALTH_GOD] = function()

	--只熔断瓜分奖池的时候
	if ngx.ctx.t_params.act and ngx.ctx.t_params.act == 'share_mission_getaward' then
		if ngx.ctx.t_params.god_type and ngx.ctx.t_params.god_type == 'pool_qu' then

			local t_taskConf 		= uu.table_value_copy(mis_data.t_share_mission[s_WEALTH_GOD].t_conf)
			
			--因为有红包逻辑,根据概率来优化熔断
			local prob = math_random(1,100)
			if t_taskConf and t_taskConf.mini_coin_prob and type(t_taskConf.mini_coin_prob) == 'number' then
				if prob <= t_taskConf.mini_coin_prob then
					return check_is_block(s_WEALTH_GOD)
				end
			end

			
		end
	end
	return t_retCode.n_OK, 'success'
end

-- 大唐中国年-迎财神状态逻辑
this.missionStatus[s_WEALTH_GOD] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	local n_code, s_desc

	if mis_data.wealth_god_check_appointment_date() == 1 and 
	t_userData.wealth_god_data and t_userData.wealth_god_data.red_envelope then
		n_code, s_desc = this.share_mission_event_core(t_userData, s_WEALTH_GOD, 27, 1)
		if n_code ~= t_retCode.n_OK then
			mis_log.print("fuckmiserror","missionStatus[s_WEALTH_GOD]-flag-1-",ngx.ctx.t_params.uin,n_code)
		end
	end

	if t_userData.wealth_god_data == nil then
		t_userData.wealth_god_data = {}
	end

	if t_userData.wealth_god_data.status == nil or t_userData.wealth_god_data.status == -1 then

		t_userData.wealth_god_data.status = -1
		--如果不存在,根据时间判断用户处于什么初始状态
		if mis_data.wealth_god_check_appointment_date() == 1 then
			t_userData.wealth_god_data.status = mis_config.t_wealthgodStatus.n_status0
			
		end

		if mis_data.wealth_god_check_appointment_date() == 2 then
			t_userData.wealth_god_data.status = mis_config.t_wealthgodStatus.n_status4
		end

		if mis_data.wealth_god_check_appointment_date() == 3 then
			t_userData.wealth_god_data.status = mis_config.t_wealthgodStatus.n_status4
		end

	end

	if t_userData.tasks[s_WEALTH_GOD][1].status == 1 and mis_data.wealth_god_check_appointment_date() == 1 then
		t_userData.wealth_god_data.status = mis_config.t_wealthgodStatus.n_status1
	end

	if mis_data.wealth_god_check_appointment_date() == 3 or mis_data.wealth_god_check_appointment_date() == 2  then
		if  t_userData.wealth_god_data.status < mis_config.t_wealthgodStatus.n_status3 then
			t_userData.wealth_god_data.status = mis_config.t_wealthgodStatus.n_status4
		end
	end

	t_resp.status = t_userData.wealth_god_data.status
	--[[local code_flag,flag_num = mis_data.wealth_god_get_award_pool(true) 
	if code_flag == t_retCode.n_OK then
		--再转换一次
		t_resp.award_pool_num = mis_data.wealth_god_get_award_pool_is_user(flag_num.pool_num)
	end--]]
	t_resp.award_pool_num = mis_data.wealth_god_get_pool_false()

	if t_resp.status == mis_config.t_wealthgodStatus.n_status5 then
		t_resp.awards = t_userData.wealth_god_data.awards
		if t_userData.wealth_god_data.code == nil then

			local appoint_code,appoint_desc= mis_calcu.new_wealth_god_code()
		
			if appoint_code ~= nil then
				--还需判断是否已有人获取了
				appoint_code =  string.sub(appoint_code, 13,#appoint_code)
			
				local t_sysUser 		= mis_data.get_user(0)
				local n_code, t_codeData = t_sysUser:get_wealth_god_code_data(appoint_code)
				if n_code ~= t_retCode.n_OK then
					mis_log.print("fuckmiserror","missionStatus[s_WEALTH_GOD]-flag-2-",ngx.ctx.t_params.uin,n_code)
					return t_retCode.n_HOT_ACTIVITY_AHEAD, t_retCodeMsg[t_retCode.n_HOT_ACTIVITY_AHEAD]
				end

				-- 密码不存在可以设置
				if t_codeData.uin == nil then
					t_userData.wealth_god_data.code = '迷你财神'..appoint_code
					t_codeData.code = appoint_code
					t_codeData.uin = ngx.ctx.t_params.uin
					t_codeData.create_code_time = uu.now()
					t_codeData.help_user_list = {}
					local flag_1,flag_2 = t_sysUser:set_wealth_god_code_data(appoint_code,t_codeData)
					if flag_1 ~= t_retCode.n_OK then
						mis_log.print("fuckmiserror","missionStatus[s_WEALTH_GOD]-flag-3-",ngx.ctx.t_params.uin,flag_1)
						return t_retCode.n_HOT_ACTIVITY_AHEAD, t_retCodeMsg[t_retCode.n_HOT_ACTIVITY_AHEAD]
					end
					mis_log.print("fuckmis","生成财神助力码-missionStatus[s_WEALTH_GOD]-flag-2-",ngx.ctx.t_params.uin,t_userData.wealth_god_data.code)
				else
					--让用户再重新拉取奖池状态时重新创建
					mis_log.print("fuckmiserror","missionStatus[s_WEALTH_GOD]-flag-4-",ngx.ctx.t_params.uin,t_codeData.uin)
				end

			end

		end

		t_resp.wealth_god_code = t_userData.wealth_god_data.code or '助力码吃年夜饭去了,再刷新试试吧'

	end


	exchange_award(s_WEALTH_GOD, t_user, t_userData, t_award, t_resp, n_exchangeType)
	t_resp.tasks=nil
	t_resp.award_num=nil

	return t_retCode.n_OK
end

-- 大唐中国年-迎财神事件核心逻辑
this.missionEventCore[s_WEALTH_GOD] = function(t_userData, s_type, n_event, n_value)
	--迎财神特殊判断
	if ngx.ctx.t_params.god_type == nil then
		n_value = 0
	end
	if	ngx.ctx.t_params.god_type and ngx.ctx.t_params.god_type ~= 'red_envelope' then
		n_value = 0
	end

	return this.share_mission_event_core(t_userData, s_type, n_event, n_value)
end

-- 大唐中国年-迎财神事件逻辑
this.missionEvent[s_WEALTH_GOD] = function(t_user, t_userData, t_resp)
	
	if ngx.ctx.t_params.god_type == nil then
		return t_retCode.n_PARAM_ERR, "PARAM_ERR_missionEvent[s_WEALTH_GOD]_1"
	end

	if ngx.ctx.t_params.god_type ~= 'red_envelope' and
		ngx.ctx.t_params.god_type ~= 'pool_qu' and 
		ngx.ctx.t_params.god_type ~= 'help' then
		return t_retCode.n_PARAM_ERR, "PARAM_ERR_missionEvent[s_WEALTH_GOD]_2"
	end


	--预约红包上报
	if ngx.ctx.t_params.god_type == 'red_envelope' and t_userData.wealth_god_data and t_userData.wealth_god_data.red_envelope == nil and 
		mis_data.wealth_god_check_appointment_date() == 1 then
		t_userData.wealth_god_data.red_envelope = 1
		t_userData.wealth_god_data.status = mis_config.t_wealthgodStatus.n_status1
		mis_log.print("fuckmis","用户预约红包上报成功",ngx.ctx.t_params.uin)
	end

	--获取瓜分奖池资格上报
	if ngx.ctx.t_params.god_type == 'pool_qu' and t_userData.wealth_god_data and t_userData.wealth_god_data.have_qu == nil and 
		mis_data.wealth_god_check_appointment_date() == 2 then
		t_userData.wealth_god_data.have_qu = 1
		t_userData.wealth_god_data.status = mis_config.t_wealthgodStatus.n_status3
		mis_log.print("fuckmis","用户瓜分奖池资格上报成功",ngx.ctx.t_params.uin)
	end

	--用户助力玩家
	if ngx.ctx.t_params.god_type == 'help' and ngx.ctx.t_params.wealth_god_code then

		if #ngx.ctx.t_params.wealth_god_code == 18 then

			local t_taskConf = uu.table_value_copy(mis_data.t_share_mission['wealth_god'].t_conf)
		if t_userData.wealth_god_data.new_user == nil then
			--先判断是否是新玩家，晚于2022年1月1日
			local check_low_valueuser = mis_bridge.query_owned_creat_recharge(ngx.ctx.t_params.uin,true)
			local flag_time = t_taskConf.low_value_user.time

			if check_low_valueuser['Account.AccountCreateTime'] == nil then
				mis_log.print("fuckmiserror","missionEvent[s_WEALTH_GOD]-flag-5没有用户数据-",ngx.ctx.t_params.uin)
				return t_retCode.n_NO_DATA, "user_not_data"
			end


			if check_low_valueuser['Account.AccountCreateTime'] >= flag_time then
				--新用户不能助力的标签
				t_userData.wealth_god_data.new_user = 1

			else
				t_userData.wealth_god_data.new_user = 2
			end

		end
		
		if t_userData.wealth_god_data.new_user == 1 then

				--0:助力成功
				--1:新用户不能参与助力
				--2:您已完成过助力
				--3:此用户助力已满
				--4:不能给自己助力哦
				--5:助力码有误哦,找不到小伙伴
				t_resp.help_status = 1
		end

		if t_userData.wealth_god_data.new_user ~= 1 then

			if t_userData.wealth_god_data.have_help then
				t_resp.help_status = 2
			end

			if t_userData.wealth_god_data.have_help == nil then

				--得判断是否还有位置助力
				local appoint_code =  string.sub(ngx.ctx.t_params.wealth_god_code, 13,#ngx.ctx.t_params.wealth_god_code)
			
				local t_sysUser 		= mis_data.get_user(0)
				local n_code, t_codeData = t_sysUser:get_wealth_god_code_data(appoint_code)
				if n_code ~= t_retCode.n_OK then
					mis_log.print("fuckmiserror","missionEvent[s_WEALTH_GOD]-flag-1-",ngx.ctx.t_params.uin,n_code)
					return t_retCode.n_HOT_ACTIVITY_AHEAD, t_retCodeMsg[t_retCode.n_HOT_ACTIVITY_AHEAD]
				end

				--存在用户才助力且自己不能助力自己
				if t_codeData.uin and t_codeData.uin ~= ngx.ctx.t_params.uin then

					--还有空位可以助力
					if #t_codeData.help_user_list < t_taskConf.assist_man_count then
						t_userData.wealth_god_data.have_help = 1
						t_resp.help_status = 0


						local aim_User 		= mis_data.get_user(t_codeData.uin)
						local aim_User_code, aim_User_Data = aim_User:get_share_mission_data(s_WEALTH_GOD)
						if aim_User_code ~= t_retCode.n_OK then
							mis_log.print("fuckmiserror","missionEvent[s_WEALTH_GOD]-flag-2-",ngx.ctx.t_params.uin,t_codeData.uin,aim_User_code)
							return t_retCode.n_HOT_ACTIVITY_AHEAD, t_retCodeMsg[t_retCode.n_HOT_ACTIVITY_AHEAD]
						end

						for i=1,#aim_User_Data.wealth_god_data.awards do
							if aim_User_Data.wealth_god_data.awards[i].status == 0  then
								aim_User_Data.wealth_god_data.awards[i].status = 1
								break
							end
						end

						local code_2, desc_2 = aim_User:set_share_mission_data(s_WEALTH_GOD, aim_User_Data)
						if code_2 ~= t_retCode.n_OK then
							mis_log.print("fuckmiserror","missionEvent[s_WEALTH_GOD]-flag-3-",ngx.ctx.t_params.uin,t_codeData.uin,code_2)
							return t_retCode.n_HOT_ACTIVITY_AHEAD, t_retCodeMsg[t_retCode.n_HOT_ACTIVITY_AHEAD]
						end

						table_insert(t_codeData.help_user_list,ngx.ctx.t_params.uin)

						local flag_1,flag_2 = t_sysUser:set_wealth_god_code_data(appoint_code,t_codeData)
						if flag_1 ~= t_retCode.n_OK then
							mis_log.print("fuckmiserror","missionEvent[s_WEALTH_GOD]-flag-4-",ngx.ctx.t_params.uin,t_codeData.uin,flag_1)
							return t_retCode.n_HOT_ACTIVITY_AHEAD, t_retCodeMsg[t_retCode.n_HOT_ACTIVITY_AHEAD]
						end
						mis_log.print("fuckmis","用户助力成功",ngx.ctx.t_params.uin,t_codeData.uin)
						else
							t_resp.help_status = 3
					end

				end

				if t_codeData.uin and t_codeData.uin == ngx.ctx.t_params.uin then
					t_resp.help_status = 4
				end

				if uu.tableIsEmpty(t_codeData) or t_codeData.uin == nil then
					t_resp.help_status = 5
				end

			end
		end

		else
			t_resp.help_status = 5
		end

		
	end

	t_resp.tasks = nil
	t_resp.status = t_userData.wealth_god_data.status 

	return t_retCode.n_OK
end

-- 大唐中国年-迎财神奖励核心逻辑
this.missionAwardCore[s_WEALTH_GOD] = function(t_userData, s_type, n_subTaskId, n_mode, t_mission, t_award)
	local t_params = ngx.ctx.t_params
	if ngx.ctx.t_params.god_type and ngx.ctx.t_params.god_type == 'red_envelope' then
		return this.share_mission_getaward_core(t_userData, s_type, n_subTaskId, n_mode, t_mission, t_award)
	end
	
	if ngx.ctx.t_params.god_type == 'help' and ngx.ctx.t_params.order and t_userData.wealth_god_data and t_userData.wealth_god_data.have_qu == 1 and 
		mis_data.wealth_god_check_appointment_date() == 3 and 
		t_userData.wealth_god_data.status == mis_config.t_wealthgodStatus.n_status5 and t_userData.wealth_god_data.awards then

		local order = tonumber(ngx.ctx.t_params.order)
		--status = 0不能领   1能领（未领取）  2已领取
		--type =    1:迷你币  2红包
		if t_userData.wealth_god_data.awards[order] and t_userData.wealth_god_data.awards[order].status == 1 then
			t_userData.wealth_god_data.awards[order].status = 2
			local minicoin_num = 0 --迷你币数量
			local hongbao_num = 0  --红包数量
			if t_userData.wealth_god_data.awards[order].type == 1 then 
				minicoin_num = tonumber(t_userData.wealth_god_data.awards[order].count)
				table_insert(t_award.items, {id = 10002, num = minicoin_num})
			else
				hongbao_num = tonumber(t_userData.wealth_god_data.awards[order].count)
				table_insert(t_award.share, {id = 'mis_item_3', num = hongbao_num})
			end
			mis_log.print("wealthgod","missionAwardCore[s_WEALTH_GOD]-领取奖励",ngx.ctx.t_params.uin,minicoin_num,hongbao_num)
			--埋点数据
			mis_log.remote_pure_day('wealth_god_get_award_pool', mis_common.table_to_json({
				key = 'getaward';
				ip = t_params.s_remoteAddr or ngx.ctx.xff or ngx.var.remote_addr or "nil";
				uin = t_params.uin;
				time = uu.now();
				country = t_params.country or 'nil';
				apiid = t_params.apiid or 'nil';
				ver = t_params.ver or 'nil';
				lang = t_params.lang or 'nil';
				hongbao_num = hongbao_num;
				minicoin_num = minicoin_num;
			}))
		end

	end

	return t_retCode.n_OK
end

-- 大唐中国年-迎财神领奖逻辑
this.missionAward[s_WEALTH_GOD] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	if ngx.ctx.t_params.god_type == nil then
		return t_retCode.n_PARAM_ERR, "PARAM_ERR_missionAward[s_WEALTH_GOD]_1"
	end

	if ngx.ctx.t_params.god_type ~= 'red_envelope' and
		ngx.ctx.t_params.god_type ~= 'pool_qu' and 
		ngx.ctx.t_params.god_type ~= 'help' then
		return t_retCode.n_PARAM_ERR, "PARAM_ERR_missionAward[s_WEALTH_GOD]_2"
	end
	
	local s_type = 'wealth_god'
	if ngx.ctx.t_params.god_type == 'red_envelope' and t_userData.wealth_god_data and t_userData.wealth_god_data.red_envelope == 1 and 
		mis_data.wealth_god_check_appointment_date() == 1 then

		t_userData.wealth_god_data.status = mis_config.t_wealthgodStatus.n_status2
	end

	if ngx.ctx.t_params.god_type == 'pool_qu' and t_userData.wealth_god_data and t_userData.wealth_god_data.have_qu == 1 and 
		mis_data.wealth_god_check_appointment_date() == 3 and 
		t_userData.wealth_god_data.status == mis_config.t_wealthgodStatus.n_status3 then
			
		t_userData.wealth_god_data.status = mis_config.t_wealthgodStatus.n_status5

		local t_taskConf 		= uu.table_value_copy(mis_data.t_share_mission[s_type].t_conf)
		
		--判断获得概率
		local prob = math_random(1,100)
		if t_taskConf and t_taskConf.mini_coin_prob and type(t_taskConf.mini_coin_prob) == 'number' and 
			t_taskConf.minicoin_award_pool and 
			t_taskConf.red_envelope_award_pool then

			local flag_is_minicoin = false
			mis_log.print("fuckmis","missionAward[s_WEALTH_GOD]-判断获得概率",ngx.ctx.t_params.uin,prob,t_taskConf.mini_coin_prob)
			local check_code,check_num,check_count = -1,0,0
			local code_flag,temp_award_pool = -1,{}
			if prob <= t_taskConf.mini_coin_prob then

				flag_is_minicoin = true

				--如果还有就要继续判断是否符合资格
				if flag_is_minicoin then

					--中了迷你币,还需要判断是否低价值用户
					local check_low_valueuser = mis_bridge.query_owned_creat_recharge(ngx.ctx.t_params.uin)
					local flag_time = t_taskConf.low_value_user.time
					local flag_time_day = t_taskConf.low_value_user.day
					if check_low_valueuser['Account.AccountCreateTime'] == nil then
						mis_log.print("fuckmiserror","missionAward[s_WEALTH_GOD]-flag-6没有用户数据-",ngx.ctx.t_params.uin)
						return t_retCode.n_NO_DATA, "user_not_data"
					end


					if check_low_valueuser['Account.AccountCreateTime'] >= flag_time then
						--低价值用户，晚于2022年1月1日
						flag_is_minicoin = false

						--新用户不能助力的标签
						t_userData.wealth_god_data.new_user = 1
						mis_log.print("fuckmis","如果还有就要继续判断是否符合资格-new_user-flag-1-",ngx.ctx.t_params.uin,check_low_valueuser['Account.AccountCreateTime'],flag_time,flag_time_day)
					else
						t_userData.wealth_god_data.new_user = 2
						mis_log.print("fuckmis","如果还有就要继续判断是否符合资格-new_user-flag-2-",ngx.ctx.t_params.uin,check_low_valueuser['Account.AccountCreateTime'],flag_time,flag_time_day)
					end

					if check_low_valueuser['Account.AccountCreateTime'] < flag_time and 
					(check_low_valueuser['leveldb.recharge'] == nil or uu.tableIsEmpty(check_low_valueuser['leveldb.recharge'])) then
						--早于2022年1月1日,且重未付费
						
						local denglu_flag, denglu_data = t_user:get_user_basic()
						if denglu_flag ~= t_retCode.n_OK then
							--找不到数据，说明不活跃，走红包
							flag_is_minicoin = false
							mis_log.print("fuckmis","如果还有就要继续判断是否符合资格-new_user-flag-3-",ngx.ctx.t_params.uin)
						else

							if denglu_data.player_last_3_login_time and #denglu_data.player_last_3_login_time >= flag_time_day then
								local login_i = #denglu_data.player_last_3_login_time - flag_time_day + 1
								if login_i <= 0 then
									login_i = 1   
								end
								if login_i > #denglu_data.player_last_3_login_time then
									login_i = #denglu_data.player_last_3_login_time
								end
								local flag_login_time = mis_common.date_to_unix(denglu_data.player_last_3_login_time[login_i])
								
								local check_time_flag = math.floor((uu.now() - flag_login_time) / 86400)

								--一个月至少要活跃五次以上才行
								if check_time_flag > 31 then
									flag_is_minicoin = false
									mis_log.print("fuckmis","如果还有就要继续判断是否符合资格-new_user-flag-4-",ngx.ctx.t_params.uin,check_time_flag,login_i,denglu_data.player_last_3_login_time)
								end
								--[[["player_last_3_login_time"] = {
                				[1] = "2021-12-22",
                				[2] = "2021-12-23",
                				[3] = "2021-12-26",
                				[4] = "2021-12-27",
                				[5] = "2021-12-28",
                				[6] = "2021-12-29",
                				[7] = "2021-12-31",
            					}--]]




							else
								--小于五天登录数据,继续走红包
								flag_is_minicoin = false
								mis_log.print("fuckmis","如果还有就要继续判断是否符合资格-new_user-flag-5-",ngx.ctx.t_params.uin)
							end
							
							
						end

					end



					if flag_is_minicoin then
						--前面查询过价值玩家后,得再判断奖池是否足够

						code_flag,temp_award_pool = mis_data.wealth_god_get_award_pool()

						--先判断奖池库存是否还有

						if code_flag ~= t_retCode.n_OK then
							mis_log.print("fuckmiserror","missionAward[s_WEALTH_GOD]-flag-4-",ngx.ctx.t_params.uin,code_flag)
							return t_retCode.n_HOT_ACTIVITY_AHEAD, t_retCodeMsg[t_retCode.n_HOT_ACTIVITY_AHEAD]
						end

						if temp_award_pool.pool_num <= 0 then
							mis_log.print("fuckmis","missionAward[s_WEALTH_GOD]-奖池小于零",ngx.ctx.t_params.uin,temp_award_pool.pool_num)
							flag_is_minicoin = false
						end

						check_code,check_num,check_count = mis_data.wealth_god_check_award_pool(temp_award_pool.minicoin_award_pool)

						if check_code ~= t_retCode.n_OK then
							mis_log.print("fuckmis","missionAward[s_WEALTH_GOD]-奖池不足",ngx.ctx.t_params.uin,temp_award_pool.minicoin_award_pool)
							flag_is_minicoin = false
						end

					end



				end

				

			end

			
			
			if flag_is_minicoin and check_num > 0 then
				
				for k,v in pairs(temp_award_pool.minicoin_award_pool) do
					if v.money == check_num then
						
						if t_userData.wealth_god_data.awards == nil then
							temp_award_pool.pool_num = temp_award_pool.pool_num - check_num
							temp_award_pool.minicoin_award_pool[k].count = temp_award_pool.minicoin_award_pool[k].count - 1
							t_userData.wealth_god_data.awards = {}

							local minicoin_flag_numbers = 0

							--每个奖励的数目
							minicoin_flag_numbers = math_floor(check_num / t_taskConf.assist_man_count)
							local minicoin_temp = {}
							minicoin_temp.count = minicoin_flag_numbers
							minicoin_temp.status= 0  --0不能领   1能领（未领取）  2已领取
							minicoin_temp.type  = 1  --1:迷你币  2红包
							for i=1,t_taskConf.assist_man_count do
								table_insert(t_userData.wealth_god_data.awards,uu.table_value_copy(minicoin_temp))
							end

							--除不尽的情况给最后一个
							local chubujin_num = check_num - (minicoin_flag_numbers * t_taskConf.assist_man_count)
							t_userData.wealth_god_data.awards[#t_userData.wealth_god_data.awards].count = t_userData.wealth_god_data.awards[#t_userData.wealth_god_data.awards].count + chubujin_num


							
							local flag_set_pool = mis_data.wealth_god_set_award_pool(temp_award_pool)
							if flag_set_pool ~= t_retCode.n_OK then
								mis_log.print("fuckmiserror","missionAward[s_WEALTH_GOD]-flag-5-",ngx.ctx.t_params.uin,flag_set_pool)
								return t_retCode.n_HOT_ACTIVITY_AHEAD, t_retCodeMsg[t_retCode.n_HOT_ACTIVITY_AHEAD]
							end
							mis_log.print("wealthgod","missionAward[s_WEALTH_GOD]当前奖池情况-",ngx.ctx.t_params.uin,check_num,temp_award_pool)
						else
							mis_log.print("fuckmis","missionAward[s_WEALTH_GOD]-抽不中迷你币",ngx.ctx.t_params.uin,t_userData.wealth_god_data.awards)
						end
						

						break
					end
				end


			else
				--中了红包
				
				local prob_red = 0
				--先把权重加起来
				for k,v in pairs(t_taskConf.red_envelope_award_pool) do
					prob_red = prob_red + (tonumber(v.prob) or 0)
				end

				local prob_red = math_random(1,prob_red)

				local prob_flag = 0

				local flag_i = 0

				for i=1,#t_taskConf.red_envelope_award_pool do
					prob_flag = prob_flag +  tonumber(t_taskConf.red_envelope_award_pool[i].prob)
					if prob_red <= prob_flag then
						flag_i = i
						break
					end
				end

				if flag_i > 0 and t_userData.wealth_god_data.awards == nil then
					t_userData.wealth_god_data.awards = {}
					local red_flag_numbers = 0
					red_flag_numbers =math_floor( tonumber(t_taskConf.red_envelope_award_pool[flag_i].envelope) / t_taskConf.assist_man_count)
					local red_temp = {}
					red_temp.count = red_flag_numbers
					red_temp.status= 0  --0不能领   1能领（未领取）  2已领取
					red_temp.type  = 2  --1:迷你币  2红包

					for i=1,t_taskConf.assist_man_count do
						table_insert(t_userData.wealth_god_data.awards,uu.table_value_copy(red_temp))
					end
					mis_log.print("wealthgod","missionAward[s_WEALTH_GOD]抽中红包-",ngx.ctx.t_params.uin,t_taskConf.red_envelope_award_pool[flag_i].envelope)
					--table_insert(t_award.share, {id = 'mis_item_3', num = tonumber(t_taskConf.red_envelope_award_pool[flag_i].envelope)})
				else
					mis_log.print("fuckmis","missionAward[s_WEALTH_GOD]-抽不中红包",ngx.ctx.t_params.uin,flag_i,t_userData.wealth_god_data.awards)
				end
				

			end

			--生成助力码
			local appoint_code,appoint_desc= mis_calcu.new_wealth_god_code()
		
			if appoint_code ~= nil then
				--还需判断是否已有人获取了
				appoint_code =  string.sub(appoint_code, 13,#appoint_code)
			
				local t_sysUser 		= mis_data.get_user(0)
				local n_code, t_codeData = t_sysUser:get_wealth_god_code_data(appoint_code)
				if n_code ~= t_retCode.n_OK then
					mis_log.print("fuckmiserror","missionAward[s_WEALTH_GOD]-flag-1-",ngx.ctx.t_params.uin,n_code)
					return t_retCode.n_HOT_ACTIVITY_AHEAD, t_retCodeMsg[t_retCode.n_HOT_ACTIVITY_AHEAD]
				end

				-- 密码不存在可以设置
				if t_codeData.uin == nil then
					t_userData.wealth_god_data.code = '迷你财神'..appoint_code
					t_codeData.code = appoint_code
					t_codeData.uin = ngx.ctx.t_params.uin
					t_codeData.create_code_time = uu.now()
					t_codeData.help_user_list = {}
					local flag_1,flag_2 = t_sysUser:set_wealth_god_code_data(appoint_code,t_codeData)
					if flag_1 ~= t_retCode.n_OK then
						mis_log.print("fuckmiserror","missionAward[s_WEALTH_GOD]-flag-2-",ngx.ctx.t_params.uin,flag_1)
						return t_retCode.n_HOT_ACTIVITY_AHEAD, t_retCodeMsg[t_retCode.n_HOT_ACTIVITY_AHEAD]
					end

					t_resp.wealth_god_code = t_userData.wealth_god_data.code
					mis_log.print("fuckmis","生成财神助力码-missionAward[s_WEALTH_GOD]-flag-1-",ngx.ctx.t_params.uin,t_resp.wealth_god_code)
				else
					--让用户再重新拉取奖池状态时重新创建
					mis_log.print("fuckmiserror","missionAward[s_WEALTH_GOD]-flag-3-",ngx.ctx.t_params.uin,t_codeData.uin)
				end

			end

			t_resp.awards = t_userData.wealth_god_data.awards
		end

	end

	if ngx.ctx.t_params.god_type == 'help' then
		t_resp.awards = t_userData.wealth_god_data.awards
	end

	t_resp.status = t_userData.wealth_god_data.status
	exchange_award(s_WEALTH_GOD, t_user, t_userData, t_award, t_resp, n_exchangeType)

	t_resp.bonus = nil
	t_resp.award_num = nil
	t_resp.tasks = nil
	return t_retCode.n_OK
end

-- 大唐中国年-上元节状态逻辑
this.missionStatus[s_LANTERN_FESTIVAL] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	local s_type			= s_LANTERN_FESTIVAL
	local t_taskConf 		= mis_data.t_share_mission[s_type]
	local n_now				= mis_data.offset_now_v2(t_taskConf)

	-- 通过配置表刷新玩家任务
	for k, v in pairs(t_taskConf.t_conf.t_mission) do
		for k2, v2 in pairs(v) do
			local n_subTaskId	= v2.n_subTaskId
			local t_task 		= t_userData.tasks[s_type][n_subTaskId]
			if t_task then
				-- 未完成的任务在配置改变后变为已完成
				if t_task.status == 0 and t_task.progress >= v2.n_target then
					t_task.status = 1
				end
				-- 已完成的任务在配置改变后变为未完成
				if t_task.status == 1 and t_task.progress < v2.n_target then
					t_task.status = 0
				end
			end
		end
	end
	
	-- 每日刷新
	if os_date("%Y%m%d", t_userData.lantern_refresh_time or 0) ~= os_date("%Y%m%d", n_now) then
		t_userData.lantern_refresh_time = n_now
		t_userData.lantern_daily_fire = 0
	end

	-- 返回希望之火数量
	t_resp.fire_num = t_userData.lantern_total_fire or 0
	t_resp.daily_fire_num = t_userData.lantern_daily_fire or 0

	return exchange_award(s_LANTERN_FESTIVAL, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 大唐中国年-上元节事件逻辑
this.missionEvent[s_LANTERN_FESTIVAL] = function(t_user, t_userData, t_resp)
	local t_params  		= ngx.ctx.t_params
	local s_type			= t_params.mission_type
	local t_taskConf 		= mis_data.t_share_mission[s_type]
	local n_now				= mis_data.offset_now_v2(t_taskConf)
	local n_code, s_desc

	-- 每日刷新
	if os_date("%Y%m%d", t_userData.lantern_refresh_time or 0) ~= os_date("%Y%m%d", n_now) then
		t_userData.lantern_refresh_time = n_now
		t_userData.lantern_daily_fire = 0
	end

	if (t_userData.lantern_daily_fire or 0) >= t_taskConf.t_conf.n_maxDailyFire then
		mis_log.day("share_mission_error", "share_mission_event extend error|" .. t_params.uin .. '|' .. s_type .. "|exceed max daily fire|" .. t_userData.lantern_daily_fire)
		return t_retCode.n_OPER_ERR, "exceed max daily fire"
	end

	t_userData.lantern_daily_fire = (t_userData.lantern_daily_fire or 0) + 1
	t_userData.lantern_total_fire = (t_userData.lantern_total_fire or 0) + 1

	-- 返回希望之火数量
	t_resp.fire_num = t_userData.lantern_total_fire
	t_resp.daily_fire_num = t_userData.lantern_daily_fire or 0

	return exchange_query(s_LANTERN_FESTIVAL, t_user, t_userData, t_resp)
end

-- 大唐中国年-上元节领奖逻辑
this.missionAward[s_LANTERN_FESTIVAL] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	local t_params 			= ngx.ctx.t_params
	local s_type			= t_params.mission_type
	local t_taskConf 		= mis_data.t_share_mission[s_type]
	local n_subTaskId		= t_params.taskId
	local t_mission, t_temp	= {}, {}
	local n_code, s_desc

	if not(t_taskConf and t_taskConf.t_conf and t_taskConf.t_conf.t_mission) then
		mis_log.day("share_mission_error", "share_mission_getaward extend config error|" .. t_params.uin .. '|' .. s_type .. "|" .. uu.to_str(t_taskConf))
		return t_retCode.n_WORK_ERR, 'The mission is not exist!'
	end

	-- 获取子任务配置
	t_temp = t_taskConf.t_conf
	for k, v in pairs(t_temp.t_mission) do
		for k2, v2 in pairs(v) do
			if v2.n_subTaskId and n_subTaskId == v2.n_subTaskId then
				t_mission = v2
				break
			end
		end
	end

	if not (t_mission and mis_uu.tableNotEmpty(t_mission)) then
		mis_log.day("share_mission_error", "share_mission_getaward extend mission not exist|" .. t_params.uin .. '|' .. s_type)
		return t_retCode.n_PARAM_ERR, "mission not exist"
	end

	-- 希望之火数量判断
	if (t_userData.lantern_total_fire or 0) < t_mission.n_target then
		mis_log.day("share_mission_error", "share_mission_getaward extend lack fire|" .. t_params.uin .. '|' .. s_type .. "|" .. uu.to_str(t_taskConf))
		return t_retCode.n_OPER_ERR, 'lack fire'
	end

	t_userData.lantern_total_fire = (t_userData.lantern_total_fire or 0) - t_mission.n_target

	-- 返回希望之火数量
	t_resp.fire_num = t_userData.lantern_total_fire
	t_resp.daily_fire_num = t_userData.lantern_daily_fire or 0

	return exchange_award(s_LANTERN_FESTIVAL, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 大唐中国年-开宝箱逻辑
this.shareRoll[s_YEAR_ROLL] = function(t_user, t_userData, t_resp)
	local t_params 			= ngx.ctx.t_params
	local n_uin 			= t_params.uin
	local s_type			= t_params.mission_type
	local t_taskConf 		= mis_data.t_share_mission[s_type]
	local n_now				= mis_data.offset_now_v2(t_taskConf)
	local s_logType			= s_type .. '_shareRoll'
	local n_code, s_desc, t_rollConf
	local n_rand, n_sum, t_bonus
	
	if not (t_taskConf.t_conf and t_taskConf.t_conf.t_shareRoll) then
		log.day_list("share_roll_error" ,"share_roll extend", "no roll config", s_type, n_uin, uu.to_str(t_userData))
		return t_retCode.n_WORK_ERR, 'no roll config'
	end

	t_rollConf = t_taskConf.t_conf.t_shareRoll
	if t_rollConf.n_totalWeight <= 0 then
		log.day_list("share_roll_error" ,"share_roll extend", "total weight is zero", s_type, n_uin, uu.to_str(t_userData))
		return t_retCode.n_WORK_ERR, 'roll config error'
	end

    -- 加权随机选择奖励
    n_rand = math_random(1, t_rollConf.n_totalWeight)
    n_sum = 0
    for _, v in ipairs(t_rollConf.t_awards) do
		if (n_sum + 1) <= n_rand and n_rand <= n_sum + v.n_weight then
			t_bonus = v
			break
		end
		n_sum = n_sum + v.n_weight
    end

    if t_bonus == nil then
		log.day_list("share_roll_error" ,"share_roll extend", "roll error", s_type, n_uin, n_rand, n_sum, uu.to_str(t_rollConf))
		return t_retCode.n_WORK_ERR, 'roll config error'
    end

	-- 抽中红包
	if t_bonus.s_itemId == mis_config.t_specialItem.s_SHARE then
		t_userData.exchange_num = (t_userData.exchange_num or 0) + t_bonus.n_num
		t_resp.bonus = {{id = "12934", num = t_bonus.n_num}}
	else
		t_resp.bonus = {{id = t_bonus.s_itemId, num = t_bonus.n_num}}
		n_code, s_desc = mis_data.add_items(t_params.uin, t_resp.bonus, s_type, 'share_roll')
		if n_code ~= t_retCode.n_OK then
			mis_log.day("share_roll_error","share_roll extend add_items error|" .. t_params.uin .. '|' .. s_type .. '|' .. uu.to_str(n_code) .. '|' .. uu.to_str(s_desc) .. '|' .. uu.to_str(t_resp.bonus))
			return n_code, s_desc
		end
	end

	--埋点数据
	mis_log.remote_pure_day(s_logType, mis_common.table_to_json({
		key = 'shareRoll';
		ip = t_params.s_remoteAddr or ngx.ctx.xff or ngx.var.remote_addr or "nil";
		uin = t_params.uin;
		time = mis_data.get_server_time();
		country = t_params.country or 'nil';
		apiid = t_params.apiid or 'nil';
		ver = t_params.ver or 'nil';
		lang = t_params.lang or 'nil';
		bonus = t_resp.bonus or {};
	}))

	return t_retCode.n_OK
end

-- 小唐人任务状态逻辑
this.missionStatus[s_TANG_PEOPLE] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(s_TANG_PEOPLE, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 小唐人任务事件逻辑
this.missionEvent[s_TANG_PEOPLE] = function(t_user, t_userData, t_resp)
	return exchange_query(s_TANG_PEOPLE, t_user, t_userData, t_resp)
end

-- 小唐人任务领奖逻辑
this.missionAward[s_TANG_PEOPLE] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(s_TANG_PEOPLE, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 大唐中国年-分享活动状态逻辑
this.missionStatus[s_SHARE_ACTIVITY] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	this.share_mission_event_core(t_userData, s_SHARE_ACTIVITY, 21, 1)
	return exchange_award(s_SHARE_ACTIVITY, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 大唐中国年-分享活动事件逻辑
this.missionEvent[s_SHARE_ACTIVITY] = function(t_user, t_userData, t_resp)
	return exchange_query(s_SHARE_ACTIVITY, t_user, t_userData, t_resp)
end

-- 大唐中国年-分享活动领奖逻辑
this.missionAward[s_SHARE_ACTIVITY] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(s_SHARE_ACTIVITY, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 大唐中国年-分享活动奖励核心逻辑
this.missionAwardCore[s_SHARE_ACTIVITY] = function(t_userData, s_type, n_subTaskId, n_mode, t_mission, t_award)
	local t_params 			= ngx.ctx.t_params
	local n_nowTime 		= mis_data.get_server_time()
	local s_logType			= s_type .. '_getaward'
	local t_subTask

	if not(s_type and n_mode and t_userData and mis_uu.tableNotEmpty(t_userData) and
			t_userData.tasks and mis_uu.tableNotEmpty(t_userData.tasks) and
			t_userData.tasks[s_type] and mis_uu.tableNotEmpty(t_userData.tasks[s_type]) and
			t_mission and mis_uu.tableNotEmpty(t_mission) and
			t_mission.t_bonus and mis_uu.tableNotEmpty(t_mission.t_bonus)) then
		mis_log.day("share_mission_error", "share_mission_getaward_core param error|" .. t_params.uin .. '|' .. s_type)
		return t_retCode.n_PARAM_ERR, "Param error"
	end

	-- 更新领奖状态
	t_subTask = t_userData.tasks[s_type][n_subTaskId]
	if not t_subTask then
		mis_log.day("share_mission_error", "share_mission_getaward_core Invalid reward|" .. t_params.uin .. '|' .. s_type)
		return t_retCode.n_OPER_ERR, 'Invalid reward'
	end

	if t_subTask.status == 1 then
		t_subTask.status 		= 2
		t_subTask.mode			= n_mode				-- 0 手动领奖；1自动领奖
		t_subTask.rewardTime 	= n_nowTime

		-- 奖励
		if t_award then
			for k, v in pairs(t_mission.t_bonus) do
				if v.s_itemId == mis_config.t_specialItem.s_SHARE then
					local n_num = math_random(1,v.n_num or 10)
					table_insert(t_award.share, {id = v.s_itemId, num = n_num})
				else
					table_insert(t_award.items, {id = v.s_itemId, num = v.n_num})
				end
			end
		end
	else
		mis_log.day("share_mission_error", "share_mission_getaward_core Invalid status|" .. t_params.uin .. '|' .. s_type .. "|" .. uu.to_str(n_subTaskId) .. "|" .. uu.to_str(n_mode) .. "|" .. uu.to_str(t_subTask.status))
		return t_retCode.n_OPER_ERR, 'Invalid status'
	end

	--埋点数据
	mis_log.remote_pure_day(s_logType, mis_common.table_to_json({
		key = 'getaward';
		ip = t_params.s_remoteAddr or ngx.ctx.xff or ngx.var.remote_addr or "nil";
		uin = t_params.uin;
		time = n_nowTime;
		country = t_params.country or 'nil';
		apiid = t_params.apiid or 'nil';
		ver = t_params.ver or 'nil';
		lang = t_params.lang or 'nil';
		type = s_type;
		task = n_subTaskId;
		mode = n_mode;
		bonus = t_award or {};
	}))

	return t_retCode.n_OK, t_userData
end

-- 花小楼状态逻辑
this.missionStatus[s_FLOWER_XIAOLOU] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	
	local t_taskConf 		= uu.table_value_copy(mis_data.t_share_mission[s_FLOWER_XIAOLOU].t_conf)
	if t_userData.awards == nil then
		t_userData.awards = {}
		for k,v in pairs(t_taskConf.unlock_award) do
			-- 0:不可用领取 1:可以领取未领取  2：已经领取
			v.stats = 0
			t_userData.awards[k] = v

		end

	end

	if t_userData.stats == nil then
		t_userData.stats = {}
		for k,v in pairs(t_taskConf.maps) do
			--0：未解锁  1：解锁
			v.stats = 0
			v.mapid = tonumber(v.mapid)
			t_userData.stats[k] = v
		end
		
	end

	t_resp.awards = t_userData.awards or {}
	t_resp.stats = t_userData.stats or {}

	t_resp.tasks=nil

	return t_retCode.n_OK
end

-- 花小楼事件核心逻辑
this.missionEventCore[s_FLOWER_XIAOLOU] = function(t_userData, s_type, n_event, n_value)
	return t_retCode.n_OK
end

-- 花小楼事件逻辑
this.missionEvent[s_FLOWER_XIAOLOU] = function(t_user, t_userData, t_resp)
	local t_params = ngx.ctx.t_params
	local n_event			= ngx.ctx.t_params.event
	if t_userData.stats and t_userData.awards then
		for k,v in pairs(t_userData.stats) do
			--未解锁
			if v.stats == 0 and v.mapid == n_event then
				t_userData.stats[k].stats = 1

				for i=1,#t_userData.awards do
					if t_userData.awards[i].stats == 0 then
						t_userData.awards[i].stats = 1
						break
					end
				end

				mis_log.print("fuckmis","missionEvent[s_FLOWER_XIAOLOU]触发",t_params.uin,n_event)

				mis_log.remote_pure_day('flower_xiaolou', mis_common.table_to_json({
				key = 'finish';
				ip = t_params.s_remoteAddr or ngx.ctx.xff or ngx.var.remote_addr or "nil";
				uin = t_params.uin;
				time = uu.now();
				country = t_params.country or 'nil';
				apiid = t_params.apiid or 'nil';
				ver = t_params.ver or 'nil';
				lang = t_params.lang or 'nil';
				mapid = n_event;
				}))

				break
			end
		end
	end
	t_resp.stats  = t_userData.stats
	t_resp.awards = t_userData.awards
	t_resp.tasks=nil
	return t_retCode.n_OK
end

-- 花小楼奖励核心逻辑
this.missionAwardCore[s_FLOWER_XIAOLOU] = function(t_userData, s_type, n_subTaskId, n_mode, t_mission, t_award)
	local t_params = ngx.ctx.t_params
	if t_userData.awards and t_userData.awards[n_subTaskId] and t_userData.awards[n_subTaskId].stats == 1 then
		t_userData.awards[n_subTaskId].stats = 2
		table_insert(t_award.items, {id = t_userData.awards[n_subTaskId].id, num = t_userData.awards[n_subTaskId].num})
		mis_log.print("fuckmis","missionAwardCore[s_FLOWER_XIAOLOU]领奖",t_params.uin,t_award.items)
		mis_log.remote_pure_day('flower_xiaolou', mis_common.table_to_json({
		key = 'getaward';
		ip = t_params.s_remoteAddr or ngx.ctx.xff or ngx.var.remote_addr or "nil";
		uin = t_params.uin;
		time = uu.now();
		country = t_params.country or 'nil';
		apiid = t_params.apiid or 'nil';
		ver = t_params.ver or 'nil';
		lang = t_params.lang or 'nil';
		bonus = t_award.items or {};
	}))

	end
	
	return t_retCode.n_OK
end

-- 花小楼奖励逻辑
this.missionAward[s_FLOWER_XIAOLOU] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	t_resp.awards = t_userData.awards
	t_resp.tasks=nil
	t_resp.bonus=nil
	return t_retCode.n_OK
end

-- 迷你派对状态逻辑
this.missionStatus[s_MINI_PARTY] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	if t_userData.tasks[s_MINI_PARTY] then
		for _, v in pairs(t_userData.tasks[s_MINI_PARTY]) do
			v.total = v.total or 0
		end
	end
	return exchange_award(s_MINI_PARTY, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 迷你派对事件逻辑
this.missionEventCore[s_MINI_PARTY] = function(t_userData, s_type, n_event, n_value)
	local t_taskConf 		= uu.table_value_copy(mis_data.t_share_mission[s_type])
	local t_mission,t_temp	= {}

	if n_event ~= 30 then
		return t_retCode.n_PARAM_ERR, 'event is error'
	end
	-- 获取子任务配置
	t_temp = t_taskConf.t_conf
	for k, v in pairs(t_temp.t_mission) do
		if k == n_event then
			t_mission = v
			break
		end
	end

	-- 更新任务进度、状态
	t_userData.tasks[s_type] = t_userData.tasks[s_type] or {}

	for k, v in pairs(t_mission) do
		local t_task = t_userData.tasks[s_type][v.n_subTaskId]
		if t_task and v.n_gainItem == n_value then
			if t_task.status == 0 and v.n_target and v.n_target >= t_task.progress then
				t_task.total	= t_task.total or 0
				t_task.total	= t_task.total + 1
				t_userData.tasks[s_type][v.n_subTaskId] = t_task
				break
			end
		end
	end

	return this.share_mission_event_core(t_userData, s_type, n_event, n_value)
end

-- 迷你派对事件逻辑
this.missionEvent[s_MINI_PARTY] = function(t_user, t_userData, t_resp)
	return exchange_query(s_MINI_PARTY, t_user, t_userData, t_resp)
end

-- 迷你派对领奖逻辑
this.missionAward[s_MINI_PARTY] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	if t_userData.tasks[s_MINI_PARTY] then
		for _, v in pairs(t_userData.tasks[s_MINI_PARTY]) do
			v.total = v.total or 0
		end
	end

	exchange_award(s_MINI_PARTY, t_user, t_userData, t_award, t_resp, n_exchangeType)

	t_resp.coin_num = 0

	for i = 1, #t_award.share do
		if t_award.share[i].id == mis_config.t_specialItem.s_SHARE then
			t_resp.coin_num = t_resp.coin_num + t_award.share[i].num
		end
	end

	return t_retCode.n_OK
end

-- 周年庆虚空入侵状态逻辑
this.missionStatus[s_VOID_INVADE] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(s_VOID_INVADE, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 周年庆虚空入侵事件触发核心逻辑
this.missionEventCore[s_VOID_INVADE] = function(t_userData, s_type, n_event, n_value)
	local t_taskConf 		= mis_data.t_share_mission[s_type]
	local n_code, s_desc, t_update = this.share_mission_event_core(t_userData, s_type, n_event, n_value)

	if n_code == t_retCode.n_OK and mis_uu.tableNotEmpty(t_update) and t_taskConf.t_conf.n_scoreUnit > 0 then
		local n_reward = 0
		for k, v in pairs(t_update) do
			n_reward = n_reward + math_floor(v/t_taskConf.t_conf.n_scoreUnit)
		end
		local t_award = {share = {{id = mis_config.t_specialItem.s_SHARE, num = n_reward}}}
		exchange_award(s_type, nil, t_userData, t_award, {}, t_taskConf.t_conf.n_exchange_type)
	end

	return n_code, s_desc
end

-- 周年庆虚空入侵事件触发
this.missionEvent[s_VOID_INVADE] = function(t_user, t_userData, t_resp)
	return exchange_query(s_VOID_INVADE, t_user, t_userData, t_resp)
end

-- 组建护卫队状态逻辑
this.missionStatus[s_CREATE_CONVOY] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	local n_code, s_desc, t_captainUser, t_captainData
	local s_type = s_CREATE_CONVOY
	local n_nowtime = mis_data.get_server_time()

	-- 护卫队成员
	t_resp.convoy_members = {}
	if t_userData.captain_uin then
		if t_user.n_uin == t_userData.captain_uin then
			t_captainUser = t_user
			t_captainData = t_userData
		else
			t_captainUser = mis_data.get_user(t_userData.captain_uin)
			n_code, t_captainData = t_captainUser:get_share_mission_data(s_CREATE_CONVOY, true)
			if n_code ~= t_retCode.n_OK then
				mis_log.day("join_convoy_error","missionStatus get captain data error|" .. t_user.n_uin .. '|' .. s_CREATE_CONVOY .. "|" .. t_userData.captain_uin)
			end
		end
		if t_captainData.convoy then
			for k, v in ipairs(t_captainData.convoy) do
				table_insert(t_resp.convoy_members, v)
			end
		end
	end

	-- 护卫队每天都能领奖一次
	if not t_userData.convoy_refresh 
	or mis_common.is_another_day(t_userData.convoy_refresh , n_nowtime) then
		t_userData.convoy_refresh = n_nowtime
		n_code, s_desc = this.share_mission_event_core(t_userData, s_type, 33, #t_resp.convoy_members)
		if n_code ~= t_retCode.n_OK then
			mis_log.day("share_mission_error","share_mission_event refresh convoy error|" .. t_user.n_uin .. '|' .. uu.to_str(n_code) .. '|' .. s_type .. '|' .. s_desc .. "|" .. uu.to_str(t_userData))
		end
	end

	return exchange_award(s_CREATE_CONVOY, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 组建护卫队事件逻辑
this.missionEvent[s_CREATE_CONVOY] = function(t_user, t_userData, t_resp)
	return exchange_query(s_CREATE_CONVOY, t_user, t_userData, t_resp)
end

-- 组建护卫队领奖逻辑
this.missionAward[s_CREATE_CONVOY] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(s_CREATE_CONVOY, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 共筑长城状态逻辑
this.missionStatus[s_BUILD_GREATWALL] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(s_BUILD_GREATWALL, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 共筑长城事件逻辑
this.missionEvent[s_BUILD_GREATWALL] = function(t_user, t_userData, t_resp)
	return exchange_query(s_BUILD_GREATWALL, t_user, t_userData, t_resp)
end

-- 共筑长城领奖逻辑
this.missionAward[s_BUILD_GREATWALL] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(s_BUILD_GREATWALL, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

-- 周年庆-开宝箱逻辑
this.shareRoll[s_ANNIVERSARY_ROLL] = function(t_user, t_userData, t_resp)
	return this.share_roll_core(t_user, t_userData, t_resp)
end

-- 迷你打工人
this.missionStatus[s_MINI_WORKER_MISSION] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(s_MINI_WORKER_MISSION, t_user, t_userData, t_award, t_resp, n_exchangeType)
end
this.missionEvent[s_MINI_WORKER_MISSION] = function(t_user, t_userData, t_resp)
	return exchange_query(s_MINI_WORKER_MISSION, t_user, t_userData, t_resp)
end
this.missionAward[s_MINI_WORKER_MISSION] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(s_MINI_WORKER_MISSION, t_user, t_userData, t_award, t_resp, n_exchangeType)
end
-- 端午节活动
this.missionStatus[s_BOAT_FESTIVAL_ACTIVITY] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	local n_code, s_desc = mis_boat_festival.share_mission_status(t_user, t_userData, t_award, t_resp, n_exchangeType)
	if n_code ~= t_retCode.n_OK then
		return n_code, s_desc
	end
	return exchange_award(s_BOAT_FESTIVAL_ACTIVITY, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

this.missionEvent[s_BOAT_FESTIVAL_ACTIVITY] = function(t_user, t_userData, t_resp)
	return exchange_query(s_BOAT_FESTIVAL_ACTIVITY, t_user, t_userData, t_resp)
end

this.missionAward[s_BOAT_FESTIVAL_ACTIVITY] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(s_BOAT_FESTIVAL_ACTIVITY, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

--绑定手机
this.bind_phone_deal[s_BOAT_FESTIVAL_ACTIVITY] = function(t_user, t_userData, phone_config, t_resp)
	return mis_boat_festival.bind_phone_rewards(t_user, t_userData, phone_config, t_resp, s_BOAT_FESTIVAL_ACTIVITY)
end
-- 全民创造
this.missionStatus[S_ALL_CREATE] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(S_ALL_CREATE, t_user, t_userData, t_award, t_resp, n_exchangeType)
end
this.missionEvent[S_ALL_CREATE] = function(t_user, t_userData, t_resp)
	return exchange_query(S_ALL_CREATE, t_user, t_userData, t_resp)
end
this.missionAward[S_ALL_CREATE] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(S_ALL_CREATE, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

this.missionAward[s_DOULUODALU] = function(t_user, t_userData, t_award, t_resp, n_exchangeType)
	return exchange_award(s_DOULUODALU, t_user, t_userData, t_award, t_resp, n_exchangeType)
end

return this
